<template>
  <div>
    <el-card style="width: 40%; margin: 10px">
      <el-form label-width="120px" :model="state.form" >
        <el-form-item label="学生电话" prop="stuPhone" >
          <el-input v-model="state.form.stuPhone" placeholder="请输入学生电话" style="width: 80%" />
        </el-form-item>
        <el-form-item label="学生姓名" prop="stuName">
          <el-input v-model="state.form.stuName" placeholder="请输入学生姓名" style="width: 80%" />
        </el-form-item>
        <el-form-item label="所在团队ID" prop="teamId">
          <el-input v-model="state.form.teamId" placeholder="请输入学生所在团队ID" style="width: 80%" />
        </el-form-item>
        <el-form-item label="所在学校ID" prop="scId">
          <el-input v-model="state.form.scId" placeholder="请输入所在学校ID" style="width: 80%" />
        </el-form-item>
        <el-form-item label="学生分数" prop="stuRecode">
          <el-input v-model="state.form.stuRecode" placeholder="请输入学生分数" disabled style="width: 80%" />
        </el-form-item>
        <el-form-item label="学生密码">
          <el-input v-model="state.form.stuPwd" placeholder="请输入学生密码" style="width: 80%" />
        </el-form-item>
      </el-form>
      <div style="text-align: center" >
        <el-button type="primary" @click="update" style="width: 80%">保存</el-button>
      </div>
      <br>
      <div style="text-align: center" >
        <el-button type="danger" @click="return1" style="width: 80%">返回</el-button>
      </div>
    </el-card>

  </div>
</template>

<script setup>

import Router from "@/router";
import request from "@/request";
import {ElNotification} from "element-plus";
import router from "@/router";
import {reactive} from "vue";

const state = reactive({
  form:{},
})
state.form=localStorage.getItem("student") ? JSON.parse(localStorage.getItem("student")) : {}

const update=()=>{
  request.post('/student/update',JSON.stringify(state.form)).then(res=>{
    if(res.code===200){
      localStorage.clear()
      localStorage.setItem("student",JSON.stringify(state.form))
      router.go(0)
      ElNotification({
        type:"success",
        message:"修改成功"
      })
    }
  })
}
const return1 = () => {
  router.push({
    path: "/student",
    query: {
      date:new Date().getTime()
    }
  })
}


</script>